package com.zjl.testSome;

import com.zjl.BaseTest;
import com.zjl.page.*;
import org.openqa.selenium.support.FindBy;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class test extends BaseTest {
    @Test(priority = 0)
    public void test_login(){
        try{
            LoginPage login=new LoginPage(driver);
            login.username.click();
            login.username.sendKeys("18332299702");
            login.password.click();
            login.password.sendKeys("123456");
            login.loginButton.click();
            Thread.sleep(2000);
            Assert.assertTrue(driver.getPageSource().contains("我"),"出错了");
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    @Test(priority = 1)
    public void test_me(){
        try {
            MePage mePage=new MePage(driver);
            mePage.me.click();
            Thread.sleep(1000);
            if(mePage.some1.isDisplayed()){
                mePage.some1.click();
                Thread.sleep(1000);
                Assert.assertTrue(mePage.some2.isDisplayed());
            }else{
                System.out.println("出问题了");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    @Test(priority = 2)
    public void test_message(){
        try {
            MessagePage mp=new MessagePage(driver);
            mp.message.click();
            Thread.sleep(1000);
            Assert.assertTrue(mp.some2.isDisplayed());

        }catch (Exception e){
            e.printStackTrace();
        }
    }
    @Test(priority = 3)
    public void test_addView_main(){
        try{
            AddViewPage adp=new AddViewPage(driver);
            adp.addView.click();;
            Thread.sleep(1000);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    @DataProvider(name = "add_view")
    public Object[][] get_add_view(){
        return new Object[][]{{"asd"},{"fdv255"},{"的说法"},{"ddaas阿斯顿"},{"1325阿斯顿"},{"123"},{"asd仔细擦152"}};
    }

    @Test(priority = 4,dataProvider = "add_view")
    public void test_addView_add(String num){
        try{
            AddViewPage adp=new AddViewPage(driver);
            adp.input.sendKeys(num);
            Thread.sleep(1000);
            adp.submit.click();
            Thread.sleep(1000);
        }catch (Exception e){
            e.printStackTrace();
        }
    }


//
//    //bug1
////    @Test(priority = 5)
////    public void test_addView_cancel(){
////        try{
////            AddViewPage adp=new AddViewPage(driver);
////            adp.cancel.click();
////            Thread.sleep(1000);
////            Assert.assertTrue(adp.some2.isDisplayed());
////        }catch (Exception e){
////            e.printStackTrace();
////        }
////    }
    @Test(priority = 6)
    public void test_community(){
        try {
            CommunityPage cp=new CommunityPage(driver);
            cp.community.click();
            Thread.sleep(1000);
            Assert.assertTrue(cp.some1.isDisplayed());
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    @Test(priority = 7)
    public void test_community_help(){
        try {
            CommunityPage cp=new CommunityPage(driver);
            cp.help.click();
            Thread.sleep(1000);
            cp.some2.click();
            Thread.sleep(1000);
            Assert.assertTrue(cp.some3.isDisplayed());
        }catch (Exception e){
            e.printStackTrace();
        }
    }
//    @Test(priority = 8)
//    public void test_iWantToHelp(){
//        try {
//            IWantToHelpPage iwthp=new IWantToHelpPage(driver);
//            iwthp.toHelp.click();
//            iwthp.text.sendKeys("asdas");
//            iwthp.name.sendKeys("sadasasd");
//            iwthp.address.sendKeys("sadaas");
//            iwthp.lost.click();
//            iwthp.phone.sendKeys("sdasd");
//            iwthp.submit.click();
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//    }
//    //bug2
//    @Test(priority = 9)
//    public void test_iWantToHelp_picture(){
//        try{
//            IWantToHelpPage iwthp=new IWantToHelpPage(driver);
//            iwthp.photo.click();
//            Thread.sleep(1000);
//            iwthp.some1.click();
//            Thread.sleep(1000);
//            iwthp.some2.click();
//            Thread.sleep(1000);
//            iwthp.photo.click();
//            Thread.sleep(1000);
//            Assert.assertTrue(iwthp.cancel.isDisplayed());
//            iwthp.cancel.click();
//            Thread.sleep(1000);
//            Assert.assertTrue(iwthp.name.isDisplayed());
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//    }
//    @Test(priority = 10)
//    public void test_IWantToFind(){
//        try {
//            IWantToFindPage want=new IWantToFindPage(driver);
//            want.toFind.click();
//            Thread.sleep(1000);
//            want.address.sendKeys("sadsa");
//            want.name.sendKeys("fddsfa");
//            want.phone.sendKeys("sdsfad");
//            want.text.sendKeys("sdfdsfad");
//            want.submit.click();
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//    }
//    //bug3
//    @Test(priority = 11)
//    public void test_IWantToFind_picture(){
//        try {
//            IWantToFindPage want=new IWantToFindPage(driver);
//            want.photo.click();
//            Thread.sleep(1000);
//            want.some1.click();
//            Thread.sleep(1000);
//            want.some2.click();
//            Thread.sleep(1000);
//            want.photo.click();
//            Thread.sleep(1000);
//            Assert.assertTrue(want.photo.isDisplayed());
//            want.cancel.click();
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//    }

//    //bug4
//    @Test(priority = 12)
//    public void test_help_search(){
//        try {
//            HelpPage hp=new HelpPage(driver);
//            hp.search.click();
//            Thread.sleep(1000);
//            hp.sInput.sendKeys("adas");
//            hp.submit.click();
//            Assert.assertEquals(hp.sInput.getText(),"");
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//    }

    //非正常运行
//    @Test(priority = 13)
//    public void test_firstPicture(){
//        try {
//            FirstPicturePage fpp=new FirstPicturePage(driver);
//            fpp.p1.click();
//            Thread.sleep(1000);
//            fpp.some1.click();
//            Thread.sleep(1000);
//
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//    }

    @Test(priority = 14)
    public void test_otherPicture(){
        try {
            OtherPicturePage opp=new OtherPicturePage(driver);
            Thread.sleep(3000);
            opp.p2.click();
            Thread.sleep(4000);
            opp.knowledge.click();
            Thread.sleep(1000);
            opp.que.click();
            Thread.sleep(1000);
            opp.allPet.click();
            Thread.sleep(1000);
            Assert.assertTrue(opp.some1.isDisplayed());

        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @Test(priority = 15)
    public void test_petInternet(){
        try{
            PetInternetPage pip=new PetInternetPage(driver);
            pip.petInternet.click();
            Thread.sleep(1000);
            Assert.assertTrue(pip.some1.isDisplayed());
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @Test(priority = 16)
    public void test_dog(){
        try {
            PetInternetPage pip=new PetInternetPage(driver);
            pip.allPet.click();
            Thread.sleep(1000);
            pip.dog.click();
            Thread.sleep(1000);
            Assert.assertTrue(pip.dogSome.isDisplayed());
            pip.returnDog.click();
            Thread.sleep(1000);
            Assert.assertTrue(pip.dog.isDisplayed());
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @Test(priority = 17)
    public void test_cat(){
        try {
            PetInternetPage pip=new PetInternetPage(driver);
            pip.cat.click();
            Thread.sleep(1000);
            pip.baliCat.click();
            Thread.sleep(1000);
            Assert.assertTrue(pip.baliSome.isDisplayed());
            pip.returnCat.click();
            Thread.sleep(1000);
            Assert.assertTrue(pip.cat.isDisplayed());
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @Test(priority = 18)
    public void test_rabbit(){
        try {
            PetInternetPage pip=new PetInternetPage(driver);
            pip.rabbit.click();
            Thread.sleep(1000);
            pip.yellowRa.click();
            Thread.sleep(1000);
            Assert.assertTrue(pip.rabbitSome.isDisplayed());
            pip.returnRabbit.click();
            Thread.sleep(1000);
            Assert.assertTrue(pip.rabbit.isDisplayed());
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @Test(priority = 19)
    public void test_mouse(){
        try {
            PetInternetPage pip=new PetInternetPage(driver);
            pip.mouse.click();
            Thread.sleep(1000);
            pip.yellowMo.click();
            Thread.sleep(1000);
            Assert.assertTrue(pip.mouseSome.isDisplayed());
            pip.returnMouse.click();
            Thread.sleep(1000);
            Assert.assertTrue(pip.mouse.isDisplayed());
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @Test(priority = 20)
    public void test_fish(){
        try {
            PetInternetPage pip=new PetInternetPage(driver);
            pip.fish.click();
            Thread.sleep(1000);
            pip.rainbow.click();
            Thread.sleep(1000);
            Assert.assertTrue(pip.fishSome.isDisplayed());
            pip.returnFish.click();
            Thread.sleep(1000);
            Assert.assertTrue(pip.fish.isDisplayed());
        }catch (Exception e){
            e.printStackTrace();
        }
    }





}
